package StudyCode.summary.mydatetime;

import java.time.Duration;
import java.time.Instant;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class UsingInstantAndDuration {
	public static void main(String[] args) {
		Instant i1 = Instant.ofEpochSecond(20);
		Instant i2 = Instant.ofEpochSecond(55);
		System.out.println("i1: " + i1);
		System.out.println("i2: " + i2);
		Duration d1 = Duration.ofSeconds(55);
		Duration d2 = Duration.ofSeconds(-17);
		System.out.println("d1: " + d1);
		System.out.println("d2: " + d2);

		System.out.println("i1.isBefore(i2): " + i1.isBefore(i2));
		System.out.println("i1.isAfter(i2): " + i1.isAfter(i2));

		Instant i3 = i1.plus(d1);
		Instant i4 = i2.minus(d2);
		System.out.println("i1.plus(d1): " + i3);
		System.out.println("i2.minus(d2): " + i4);

		Duration d3 = d1.plus(d2);
		System.out.println("d1.plus(d2): " + d3);
	}
}
